/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package doc2db.interfaces.xmledit;

import doc2db.Keey;
import doc2db.Launcher;
import doc2db.UserProp;
import doc2db.fileWorker.FileBeginer;
import doc2db.interfaces.action.CreateHtmlFile;
import java.awt.Color;
import java.awt.Container;
import java.awt.Cursor;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;

/**
 *
 * @author yuriy
 */
public class HelpFrame extends JDialog{
    private JEditorPane paneHtmlTags = new JEditorPane();
    private JEditorPane panePatterns = new JEditorPane();

    public HelpFrame(JDialog d){
        super (d, "Справка", true);
        this.initComponent();
    }

    private void initComponent() {
        setSize(640, 480);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
        setFont(UserProp.paneFont);
        try {
            String path = FileBeginer.resurse_resurseFolderMenu + Keey.sp + "help.png";
            setIconImage(ImageIO.read(new File(path)));
        } catch (IOException ex) {
        }

        Container content = getContentPane();
        JTabbedPane tp = new JTabbedPane();
        tp.setTabPlacement(JTabbedPane.LEFT);
        tp.addTab("HTML", new JScrollPane(paneHtmlTags));
        tp.addTab("Pattern", new JScrollPane(panePatterns));
        content.add(tp);
        
        initPane(paneHtmlTags, "htmltokens.html");
        initPane(panePatterns, "Pattern.html");
    }

    public void initPane(JEditorPane pane, String file) {
        CreateHtmlFile chf = new CreateHtmlFile(pane, null, null);
        chf.setMyPage(Launcher.getText(file));
        pane.setCursor(new Cursor(Cursor.TEXT_CURSOR));
        pane.setEditable(false);
        pane.setBackground(Color.WHITE);
    }

}
